{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 问题：小费数据集，用总金额预测小费"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数据集字段说明\n",
    "- 消费总金额(totall_bill)(不含小费)\n",
    "- 小费金额(tip)\n",
    "- 顾客性别(sex)\n",
    "- 消费的星期(day)\n",
    "- 消费的时间段(time)\n",
    "- 用餐人数(size)\n",
    "- 顾客是否抽烟(smoker)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_excel(\"小费数据集.xlsx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>total_bill</th>\n",
       "      <th>tip</th>\n",
       "      <th>sex</th>\n",
       "      <th>smoker</th>\n",
       "      <th>day</th>\n",
       "      <th>time</th>\n",
       "      <th>size</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>16.99</td>\n",
       "      <td>1.01</td>\n",
       "      <td>Female</td>\n",
       "      <td>No</td>\n",
       "      <td>Sun</td>\n",
       "      <td>Dinner</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10.34</td>\n",
       "      <td>1.66</td>\n",
       "      <td>Male</td>\n",
       "      <td>No</td>\n",
       "      <td>Sun</td>\n",
       "      <td>Dinner</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>21.01</td>\n",
       "      <td>3.50</td>\n",
       "      <td>Male</td>\n",
       "      <td>No</td>\n",
       "      <td>Sun</td>\n",
       "      <td>Dinner</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   total_bill   tip     sex smoker  day    time  size\n",
       "0       16.99  1.01  Female     No  Sun  Dinner     2\n",
       "1       10.34  1.66    Male     No  Sun  Dinner     3\n",
       "2       21.01  3.50    Male     No  Sun  Dinner     3"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 散点图观察效果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x7fe74fb25700>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD2CAYAAAD24G0VAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAeX0lEQVR4nO3dbYxc1XkH8P+z4zHMQutZw0rBUy+mVF0qx5iNN8HKElU4DW7imG4glPCiJs0HS5EipQRtZUuuMJUrrK5aSpWoFVJRq4YQ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APyliKwCUAbwEeTn2i0PANjT/HkbgO8ppZYA/Cfycf03i8iLIvIkgE8iwb8/A3f0LgHwdvPnXwJYm2JfYqWU+qlS6kUR+RyA1Vj+5pGXa39XKbUA4Dksf4Dl5u8OACJyO4BZAD9u3pSr6wfwCoA/UUp9DMvfuG5CgtfPwB29twCsaf68Bj2+d4OI3AjgawB2Avg5cnLtInKJiFwA4ONY/mr8YeTk2ps+i+VR5ncAbMHyPh15uv7TAL7f/Pk1AEtI8PoZuKP3DIAbmj9vA/Bsin2JlYh8CMAEgB1KqXeQo2sHcDeAW5RSiwAWAPwZ8nPtUErd3sztfgHL37S+CeAGEekD8Nvo8esH8HUAX2he74ex/O8hsb8/A3f0HgZQEZGXsfyp/EzK/YnTF7H8NfGwiPwQQBH5ufZvAviyiDwP4BcA/g75uXYnfw3gMwBeBnBIKfW/Kfcnbt8A8IcAXgDwT0j478+Vk0REhuGIm4jIMAzcRESGYeAmIjIMAzcRkWEYuImIDMPATURkmP8HCl1FCPSkFMcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(df[\"total_bill\"], df[\"tip\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 训练回归预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LinearRegression()"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lr = LinearRegression()\n",
    "lr.fit(df[\"total_bill\"].to_numpy().reshape(-1, 1), df[\"tip\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2.70463616, 2.00622312, 3.12683472, 3.40725019, 3.5028225 ,\n",
       "       3.57633966, 1.84133463, 3.74332864, 2.49983836, 2.47253198])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "predicts = lr.predict(df[\"total_bill\"].to_numpy().reshape(-1, 1))\n",
    "predicts[:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD2CAYAAAD24G0VAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3dfXhU1Z0H8O/JZIABJAGJCJEXwRoUwmt8qah9QCsqSiNqrdRarFu623ZbrU+60NaKXVrYUtvarbsuu760XUsR0VQXlVXpWmtFSQwRsaIir4MvaEwEM8AkOftHcpO5M/feuffOfZ37/TwPzxPuvJxzJ5nfnPnd8ztHSClBREThUeJ3B4iIyBoGbiKikGHgJiIKGQZuIqKQYeAmIgqZUrcbGD58uBw3bpzbzRARFZXGxsYPpJQVWre5HrjHjRuHhoYGt5shIioqQog9ercxVUJEFDIM3EREIcPATUQUMgzcREQhw8BNRBQyDNxERCFjajqgECIO4GEp5eVCiAEAHgIwGsArAK6XXGKQiKhXfVMSqzbuwIHWFEaVJ1A3twq10ysde/68I24hRAJAI4DP9hy6DsB+KeVUAEMzjhMRRV59UxJLH96GZGsKEkCyNYWlD29DfVPSsTbyBm4pZUpKOQXA/p5DcwA81fPzJgCzHesNEVHIrdq4A6l0p+pYKt2JVRt3ONaGnRz38QDaen7+GMCw7DsIIRYLIRqEEA0HDx4spH9ERKFyoDVl6bgddgL3BwDKen4u6/m/ipRytZSyRkpZU1GhWWpPR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ANzZ8/MxAMsQnXN/EsDPhRClAMoBzEB0zl1xJ4ClPT/PAfCUlLILwLOIxvlfKYR4SQixHsAF8PD3z8DtvOMBtPX8/DGAYT72xVVSyjellC8JIa4A0A/d3zyicu6HpZTtAJ5H9wdYZH7vACCEWAigGcBrPYcidf4AdgK4VUp5Jrq/cS2Ah+fPwO28DwCU9fxchiJfu0EIMR/AtwFcDuB9ROTchRDHCyH6AzgH3V+NJyMi597jMnSPMv8AYCa61+mI0vm3AHi65+fdALrg4fkzcDvvGQAX9fw8B8CffOyLq4QQJwKoAzBPSnkIETp3ALcAuFpK2QmgHcCPEZ1zh5RyYU9u9wvo/qZ1F4CLhBAlAD6DIj9/AN8B8IWe852M7r8Hz37/DNzOewBApRDiFXR/Kj/jc3/c9GV0f03cKIT4C4A4onPudwH4ihDiBQAfArgH0Tl3Lb8CcCmAVwBskFK+5XN/3PZrADcAeBHAI/D498/KSSKikOGIm4goZBi4iYhChoGbiChkGLiJiEKGgZuIKGQYuImIQub/AbxeKjziG3leAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(df[\"total_bill\"], df[\"tip\"])\n",
    "plt.plot(df[\"total_bill\"], predicts)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 预测小费"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "total_bill = 40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([5.12125031])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "predicts = lr.predict([[total_bill]])\n",
    "predicts"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
